package org.example.controller;

import org.example.model.common.dtos.ResponseResult;
import org.example.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@CrossOrigin
@RestController
@RequestMapping("/file")
public class FileController {

    @Autowired
    private FileService fileService;

    /**
     * 文件上传
     */
    @PostMapping("/upload-file")
    public ResponseResult UploadFile(@RequestParam("file")MultipartFile file) throws IOException {
        return ResponseResult.okResult(fileService.UploadFile(file));
    }
}
